package com.key.w8.common;

/**
 * @Author: k8
 * @CreateTime: 2025-02-19
 * @Version: 1.0
 */



import java.io.Closeable;

/**
 * 适配h1，h2不同类型的Connection
 * */
public interface ConnectionAdapter extends Closeable {
    /**
     * 建立连接后，客户端和服务器通过添加handler在接收到请求和响应后执行回调，适配h1和h2
     */



    /**
     * The state of connection
     */
    enum State {

        /**
         * The object of connection has been created in memory,
         * but the channel not be active yet.
         */
        INITIAL(-1),
        /**
         * It means the channel has be active and can calls written method
         */
        CREATED(0),
        SHUTDOWN(1),
        /**
         * The connection has been closed
         */
        CLOSED(2);
        public final int value;

        State(int value) {
            this.value = value;
        }
    }


    State state();

    /**
     * set the current state of http2 connection
     * @param state state
     */
    void state(State state);



}
